/*
 * Copyright (c) 2025 Huawei Technologies Co., Ltd.
 * openUBMC is licensed under Mulan PSL v2.
 * You can use this software according to the terms and conditions of the Mulan PSL v2.
 * You may obtain a copy of Mulan PSL v2 at:
 *         http://license.coscl.org.cn/MulanPSL2
 * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
 * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
 * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
 * See the Mulan PSL v2 for more details.
 */

#ifndef MC_BUILTINS_H
#define MC_BUILTINS_H

#include <iostream>
#include <type_traits>

#include "builtins/cast.h"
#include "builtins/detail/set_impl.h"
#include "builtins/dict.h"
#include "builtins/dict_views.h"
#include "builtins/global_functions.h" // 必须在所有容器头文件之后
#include "builtins/lambda.h"
#include "builtins/list.h"
#include "builtins/set.h"
#include "builtins/string.h"
#include "builtins/tuple.h"
#include "builtins/unpack.h"

namespace mcpy {

// print函数的可变参数实现
template <typename... Args>
void print(Args&&... args) {
    if constexpr (sizeof...(args) == 0) {
        std::cout << std::endl;
    } else {
        bool first            = true;
        auto print_with_delim = [&first](const auto& arg) {
            if (!first) {
                std::cout << ' ';
            }
            std::cout << arg;
            first = false;
        };
        (print_with_delim(args), ...);
        std::cout << std::endl;
    }
}

// min函数的可变参数实现
template <typename T>
constexpr const T& min(const T& a) {
    return a;
}

template <typename T>
constexpr const T& min(const T& a, const T& b) {
    return std::min(a, b);
}

template <typename T, typename... Args>
constexpr const T& min(const T& a, const T& b, const Args&... args) {
    return min(std::min(a, b), args...);
}

template <typename T>
constexpr const T& max(const T& a, const T& b) {
    return std::max(a, b);
}

template <typename T, typename... Args>
constexpr const T& max(const T& a, const T& b, const Args&... args) {
    return max(std::max(a, b), args...);
}

} // namespace mcpy

#endif // MC_BUILTINS_H